package com.kinyx.framework.enums.impl;

import com.kinyx.framework.enums.IErrorCodeEnum;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
 * 错误编码枚举（定义错误用于开发者快速定位错误来源，不可以直接在应用层输出错误信息，因而不支持国际化。）
 */
@Getter
@RequiredArgsConstructor
public enum ErrorCode0 implements IErrorCodeEnum {

	SUCCESS(0, null), //

	CanNotConvertType(1, "can not convert type from [${from}] to [${to}]"), //

	ValueMoreThenMaxValue(11, "value [${value}] more than max value [${maxValue}]"), //
	ValueLessThenMinValue(12, "value [${value}] less than min value [${minValue}]"), //
	MinValueMoreThenMaxValue(13, "min value [${minValue}] more than max value [${maxValue}]"), //

	FileDoesNotExists(31, "file [${fileName}] does not exists"), //
	DirectoryDoesNotExists(32, "directory [${directoryName}] does not exists"), //
	IsNotAFile(33, "[${fileName}] is not a file"), //
	IsNotADirectory(34, "[${directoryName}] is not a directory"), //
	FileIsNotReadable(35, "file [${fileName}] can not readable"), //
	FileIsNotWriteable(36, "file [${fileName}] can not writable"), //

	StartIndexLessThenMinIndex(41, "start index [${startIndex}] less than min index [${minIndex}]"), //
	EndIndexMoreThenMaxIndex(42, "end index [${endIndex}] more than max index [${maxIndex}]"), //
	StartIndexMoreThenEndIndex(43, "start index [${startIndex}] more than end index [${endIndex}]"), //

	;

	/** 错误编码 */
	private final int errorCode;
	/** 错误信息 */
	private final String errorMessage;

	@Override
	public String getErrorMessage() {
		return this.errorMessage != null ? this.errorMessage : this.toString();
	}

	@Override
	public int section() { return 0; }

}
